package com.rainy.micservice.zuul;

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.ComponentScan;

@EnableEurekaClient
@EnableZuulProxy
@SpringCloudApplication
@ComponentScan(basePackages = {"com.rainy.micservice.zuul.config"})
@EnableCircuitBreaker //对Hystrix熔断机制的支持
public class ZuulApplication {

    public static void main(String[] args) {

        new SpringApplicationBuilder(ZuulApplication.class).web(true).run(args);

    }

    /**
     * 使用正则表达式方式路由，
     * 添加该方式后,在原有的服务中，appname-v1,
     * 如 micoserice-zipkin-v1
     * @return
     */
	/*@Bean
	public PatternServiceRouteMapper serviceRouteMapper(){
		return new PatternServiceRouteMapper(
				"(?<name>^.+)-(?<version>v.+$)",
				"${version}/${name}");
	}*/

    /**
     * 添加zuul过滤器Bean
     * @return RequestLogFilter
     */
//    @Bean
//    public RequestLogFilter getRequestLogFilter(){
//        return new RequestLogFilter();
//    }

}